/*
 * @Author: your name
 * @Date: 2020-05-23 12:59:43
 * @LastEditTime: 2020-05-26 14:20:46
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \huadidbei\app.js
 */
const Koa = require("koa"),
    Router = require("koa-router");
const app = new Koa(),
    router = new Router(),
    path = require("path"),
    render = require("koa-art-template"),
    static = require('koa-static');

//art模板引擎配置开始
render(app, {
    root: path.join(__dirname, "views"),
    extname: ".html",
    debug: process.env.NODE_ENV !== "production",
});
//配置art结束
//路由配置开始
router
    .get("/", async (ctx) => {
        ctx.body = "welcome";
    })
    .get("/map", async (ctx) => {
        await ctx.render('map')
    })
    .get("/pie",async(ctx)=>{
        await ctx.render('pie')
    })
    .get("/demo",async(ctx)=>{
        await ctx.render('demo')
    })
//路由配置结束
app
    .use(static('static'))
    .use(router.routes())
    .use(router.allowedMethods())
    .listen(3000);
console.log("127.0.0.1:3000");